<template>
  <div>
     <div class="bians">
      <el-input placeholder="请输入查询内容" v-model="search.searchValue" class="input-with-select">
        <el-select v-model="search.searchType" slot="prepend" placeholder="请选择" style="width:120px">
          <el-option label="承租方姓名" value="name"></el-option>
          <el-option label="承租方账号" value="username"></el-option>
          <el-option label="承租方身份证号" value="identityCard"></el-option>
        </el-select>
        <el-button slot="append" icon="el-icon-search" @click="serchCart"></el-button>
      </el-input>
    </div>
     <el-table :data="cartData.rows" border style="width: 100%" height="340px">
      <el-table-column fixed prop="username" label="承租方账号" width="150%"></el-table-column>
      <el-table-column fixed prop="name" label="承租方姓名" width="140%"></el-table-column>
      <el-table-column fixed prop="nickname" label="承租方网名" width="140%"></el-table-column>
      <el-table-column prop="identityCard" label="承租方身份证号" width="200%"></el-table-column>
      <el-table-column prop="phoneNumber" label="联系方式"></el-table-column>
      <el-table-column  label="操作"  width="200%">
        <template slot-scope="scope">
          <el-button size="mini" @click="updateAdm(scope.row._id)">申请通过</el-button>
          <el-button type="primary" size="mini" @click="removeAmd(scope.row)">忽略</el-button>

        </template>
      </el-table-column>
    </el-table>
      
     <div class="block">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageData.currentPage"
        :page-sizes="[4,5,6,7]"
        :page-size="pageData.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pageData.total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import { createNamespacedHelpers } from "vuex";
const {
  mapState,
  mapGetters,
  mapMutations,
  mapActions
} = createNamespacedHelpers("RentalList");
export default {
   data() {
    return {
      //       search: {
      //   searchType: "",
      //   searchValue: ""
      // },
        centerDialogVisible: false,
    };
  },
  created() {
    this.getcartsync();
  },
   computed: {
    ...mapState(["cartData","pageData","search"])
  },
   methods: {
    ...mapMutations(["changepageSize", "changePage","getRenCart"]),
    ...mapActions([
      "getcartsync",
      "updatecartsync",
      "handleCurrentChange",
      "handleSizeChange",
      ]),
    removeAmd(row) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.deleteAdm(row);
          this.getcartsync();
          this.$message({
            type: "success",
            message: "删除成功!"
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除"
          });
        });
    },
      updateAdm(id){
       this.updatecartsync(id);
       console.info(id)
      },
      serchCart(){
         this.getcartsync();
      },
      
  },
  // watch:{
  //       pageData(){
  //         if(search.searchType != "" && search.searchValue){
  //           this.handleCurrentChange(this.search)
  //           this.handleSizeChange(this.search)
  //         }
  //       }
  //     }
}
</script>

<style>
.el-table{
  line-height: 25px;
}
.el-pagination{
  height: 30px;
  margin-top: 10px;
}
</style>